﻿/*
 * @Description:楼盘字典操作日志页面js
 * @Author:yangpl
 * @Date:2014-11-20
 */

var EstateLog = {};

//日志页面初始化js
EstateLog.init = function () {
    //初始化功能模块
    var tempFunctionModule = dataBind.getRealDataByType("101"), tempFunctionModuleOption = "", tempOperationItemKeyId = dataBind.getRealDataByType("102"), tempOperationItemOption = '<option value="-1" selected="selected">全部操作项</option>', tempOperationTypeKeyId = dataBind.getRealDataByType("103"), tempOperationTypeOption = '<option value="-1" selected="selected">全部操作类型</option>';
    $("#selFunctionModuleKeyId").append(function () {
        for (var i = 0; i < tempFunctionModule.length; i++) {
            tempFunctionModuleOption += '<option value="' + tempFunctionModule[i].ItemValue + '">' + tempFunctionModule[i].ItemText + '</option>';
        }
        return tempFunctionModuleOption;
    });
    $("#selOperationItemKeyId").append(function () {
        for (var i = 0; i < tempOperationItemKeyId.length; i++) {
            tempOperationItemOption += '<option value="' + tempOperationItemKeyId[i].ItemValue + '">' + tempOperationItemKeyId[i].ItemText + '</option>';
        }
        return tempOperationItemOption;
    });
    $("#selOperationTypeKeyId").append(function () {
        for (var i = 0; i < tempOperationTypeKeyId.length; i++) {
            tempOperationTypeOption += '<option value="' + tempOperationTypeKeyId[i].ItemValue + '">' + tempOperationTypeKeyId[i].ItemText + '</option>';
        }
        return tempOperationTypeOption;
    });

    $("#selFunctionModuleKeyId").change(function () {
        $("#selOperationTypeKeyId").html(tempOperationTypeOption);
        if ($(this).val() == "-1") {
            $("#selOperationItemKeyId").html(tempOperationItemOption);
        } else {
            var tempCurrentKeyid = $(this).val(), tempStrOption = '<option value="-1" selected="selected">全部操作项</option>';
            for (var i = 0; i < SysParamItemRel.length; i++) {
                if (tempCurrentKeyid == SysParamItemRel[i].ParentItemKeyId) {
                    for (var j = 0; j < tempOperationItemKeyId.length; j++) {
                        if (SysParamItemRel[i].SubItemKeyId == tempOperationItemKeyId[j].ItemValue) {
                            tempStrOption += '<option value="' + tempOperationItemKeyId[j].ItemValue + '">' + tempOperationItemKeyId[j].ItemText + '</option>';
                        }
                    }
                }
            }

            $("#selOperationItemKeyId").html(tempStrOption);

        }
    });
    $("#selOperationItemKeyId").change(function () {
        $("#selOperationTypeKeyId").html("");
        if ($(this).val() == "-1") {
            $("#selOperationTypeKeyId").html(tempOperationTypeOption);
        } else {
            var tempCurrentKeyid = $(this).val(), tempStrOption = '<option value="-1" selected="selected">全部操作类型</option>';
            for (var i = 0; i < SysParamItemRel.length; i++) {
                if (tempCurrentKeyid == SysParamItemRel[i].ParentItemKeyId) {
                    for (var j = 0; j < tempOperationTypeKeyId.length; j++) {
                        if (SysParamItemRel[i].SubItemKeyId == tempOperationTypeKeyId[j].ItemValue) {
                            tempStrOption += '<option value="' + tempOperationTypeKeyId[j].ItemValue + '">' + tempOperationTypeKeyId[j].ItemText + '</option>';
                        }
                    }
                }
            }

            $("#selOperationTypeKeyId").html(tempStrOption);

        }
    });

    var myDate = new Date();
    var currentDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
    $("#txtEndTime").val(currentDate);
    var tempKeyword = "可输入操作人\\关键字";
    $("#txtKeyword").css("color","gray");
    $("#txtKeyword").focus(function () {
        if ($(this).val() == tempKeyword) {
            $(this).val("");
            $(this).css("color", "");
        }
    }).blur(function () {
        if (other.trim($(this).val()).length <= 0) {
            $(this).val(tempKeyword);
            $(this).css("color", "gray");
        }
    });
};

